package com.zhongya.example.fragment.demo

import androidx.recyclerview.widget.LinearLayoutManager
import com.zhongya.example.R
import com.zhongya.example.adapter.ExampleAdapter
import com.zhongya.example.bean.ExampleBean
import com.zhongya.example.databinding.ExampleFragmentDemoBinding
import com.zhongya666.library.base.fragment.BaseDbFragment
import com.zhongya666.library.ext.initClose
import com.zhongya666.library.view.nav
import com.zhongya666.library.view.navigateAction

class DemoFragment : BaseDbFragment<ExampleFragmentDemoBinding>(R.layout.example_fragment_demo) {
    override fun initView() {

        mDatabind.include.toolbar.initClose("案例教程") {
            nav().popBackStack()
        }

        val list = arrayListOf<ExampleBean>()
        val bean1 = ExampleBean("Dialog","一个简单方便的弹框,几行代码轻松搞定,可轻松修改字体属性、窗口尺寸。")
        val bean2 = ExampleBean( "倒计时按钮","一个简单方便的倒计时按钮，xml几行代码轻松配置属性，可修改按钮的字体属性和按钮属性,一个按钮可使用整个项目！")

        list.add(bean1)
        list.add(bean2)
        val adapter = ExampleAdapter(list)
        mDatabind.rv.adapter = adapter
        mDatabind.rv.layoutManager = LinearLayoutManager(context)

        adapter.setOnItemClickListener { adapter, view, position ->
            when(position){
                0 -> {
                    nav().navigateAction(R.id.action_demoFragment_to_dialogFragment)
                }
                1 -> {
                    nav().navigateAction(R.id.action_demoFragment_to_timeButtonFragment)
                }
            }
        }
    }

    override fun createObserver() {

    }

    override fun lazyLoadData() {

    }
}